﻿using System.Collections;
using System.Collections.Generic;

namespace LeRenard.Core.Validation
{
    /// <summary>
    /// Defines an object that can be validated.
    /// </summary>
    public interface IValidatable
    {
        /// <summary>
        /// Determines whether the specified object is valid.
        /// </summary>
        bool IsValid { get; }

        /// <summary>
        /// Determines whether the specified object is valid.
        /// </summary>
        /// <returns>A collection that holds failed-validation information.</returns>
        IEnumerable<ValidationResult> Validate();

        /// <summary>
        /// Adds a <see cref="IValidationRule"/> to this object.
        /// </summary>
        /// <param name="validationRule">The rule to add.</param>
        void AddRule<TObject>(IValidationRule<TObject> validationRule) 
            where TObject : IValidatable;
    }
}
